<!DOCTYPE html>

<ui:composition template="../template.xhtml"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:p="http://primefaces.org/ui">
    
    <ui:define name="content">
        <div class="col-md-6">
            <h4>Mantenimiento de Personas</h4>
            <h:form>
                <div>
                    <h:commandButton value="Nuevo" class="btn btn-default" action="#{persona.verFormulario(null)}" />                                 
                </div>
                <br/>
                <div class="input-group input-group-sm" style="padding-bottom: 5px;">
                        <h:inputText class="form-control input-sm" id="txtBuscar" onkeypress="if(event.keyCode == 13) { return false; }" value="#{persona.cadenaBusqueda}"/>
                        <span class="input-group-addon">
                            <h:commandButton value="Buscar" class="btn btn-default  btn-xs" action="#{persona.buscar()}" style="padding-bottom: 0px; padding-top: 0px;"/>
                        </span>
                    </div>   
                <h:panelGroup  rendered="#{persona.listaPersonas.size() > 0}" id="pnlnorows">      
                    <div class="panel panel-default">
                        <div class="table-responsive">
                            <p:dataTable var="p" value="#{persona.listaPersonas}" 
                                         paginator="true" rows="10"   paginatorPosition="bottom" 
                                         paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                         rowsPerPageTemplate="5,10,15"   styleClass="table table-bordered table-striped table-condensed"
                                         style="font-size: 12px;">  
                                <p:column>  
                                    <div style="text-align: center;">
                                        <h:commandLink action="#{persona.verFormulario(p)}" class="btn btn-default btn-xs" title="Editar">                                     
                                            <h:graphicImage  library="pics" name="edit.png" width="15px;"/>                                    
                                        </h:commandLink>
                                    </div>
                                </p:column> 
                                <p:column >    				
                                    <f:facet name="header">C&#243;digo</f:facet>    				
                                    #{p.codigo}
                                </p:column>
                                <p:column >    				
                                    <f:facet name="header">Nombre</f:facet>    				
                                    #{p.nombre}
                                </p:column>
                                <p:column >
                                    <f:facet name="header">Apellido</f:facet>
                                    #{p.apellido}
                                </p:column>                              
                                <p:column>
                                    <div style="text-align: center;">
                                        <h:commandButton class="btn btn-default btn-xs" action="#{persona.eliminar(p)}" value="X" title="Eliminar"/>
                                    </div>
                                </p:column> 
                            </p:dataTable> 
                        </div>
                    </div>
                </h:panelGroup>
            </h:form>
            
        </div>
    </ui:define>
</ui:composition>
